package com.gzyj.jtt808.v2019.protocol.yuebiao;

import io.netty.buffer.ByteBuf;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * @author lhj
 */
@Data
@ApiModel("轮胎状态监测功能报警信息")
public class AlarmOrEventProperty implements Serializable {
    @ApiModelProperty("胎压报警位置")
    public byte[] TirePressureAlarmPosition;

    @ApiModelProperty("报警/事件类型")
    public Integer AlarmOrEventType;
    @ApiModelProperty("胎压")
    public Integer TirePressure;
    @ApiModelProperty("胎温")
    public Integer TireTemperature;

    @ApiModelProperty("电池电量")
    public Integer BatteryLevel;

    public void encode(ByteBuf buf){
        buf.writeBytes(this.TirePressureAlarmPosition);
        buf.writeShort(this.AlarmOrEventType);
        buf.writeShort(this.TirePressure);
        buf.writeShort(this.TireTemperature);
        buf.writeShort(this.BatteryLevel);
    }

    public AlarmOrEventProperty decode(ByteBuf buf){

        this.TirePressureAlarmPosition=new byte[2];
        buf.readBytes(this.TirePressureAlarmPosition);

        this.AlarmOrEventType=buf.readUnsignedShort();
        this.TirePressure=buf.readUnsignedShort();
        this.TireTemperature=buf.readUnsignedShort();
        this.BatteryLevel=buf.readUnsignedShort();
        return this;
    }
}
